<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!-- 引入meta文件 -->
<%@include file="/WEB-INF/pages/common/meta.jspf"%>

<!-- 引入header文件 -->
<%@include file="/WEB-INF/pages/common/header.jspf"%>

<!-- 引入menu文件 -->
<%@include file="/WEB-INF/pages/common/menu.jspf"%>

<div style="margin-left: 40px;">
<input type="hidden" id="sId" value="${sId}">
<c:forEach items="${courseList}" var="course">
		<c:choose>  
			   <c:when test="${course.checked}">
			     	<div><input type="checkbox" value="${course.cId}" name="cId" checked="checked" />${course.cName}</div>
			   </c:when>  
			   <c:otherwise>  
			   		<div><input type="checkbox" value="${course.cId}" name="cId"/>${course.cName}</div>
			   </c:otherwise>  
		</c:choose> 
</c:forEach>

	<input id="saveBtn" class="btn btn-primary radius" type="button" value="&nbsp;&nbsp;保存&nbsp;&nbsp;">
</div>

<!-- 引入footer文件 -->
<%@include file="/WEB-INF/pages/common/footer.jspf"%>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
$(function(){
	function save(){
		var obj=document.getElementsByName("cId");
		var check_val = [];
	    for(k in obj){
	        if(obj[k].checked)
	            check_val.push(obj[k].value);
	    }
		$.ajax({
			url:"${basePath}/course/save",
			type:'post',
			data:{
				sId:$("#sId").val(),
				cIds:check_val.toString()
			},
			dataType:'json',
			success:function(result){
				if(result.code==200){
					parent.reloadParent();
					parent.layer.closeAll();
				}else{
					layer.msg('保存失败');
				}
			},
			error:function(e){
				console.log("请求后台出错"+JSON.stringify(e));
			}
		});
	}
	$("#saveBtn").click(function(){
		save();
	});
	
});
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>